<?php
namespace app\index\controller;

class Certification extends CheckMember
{
    /**
     * 实名认证
     * @return \think\response\View
     */
    public function index()
    {
        $member_id = session('member_id');
        $data = $this->local_invoke_api('get_certification_info', ['member_id' => $member_id]);
        $this->assign('data', $data['data']);

        // 进入审核页面
        return view('audit');
    }

    /**
     * 保存实名认证信息
     * @return \think\response\Json
     */
    public function application() {
        if (request()->isAjax()) {
            $param = input('param.');
            $param['member_id'] = session('member_id');
            $data = $this->local_invoke_api('save_certification', $param);
            return json($data);
        } else {
            $member_id = session('member_id');
            $data = $this->local_invoke_api('get_certification_info', ['member_id' => $member_id]);
            $this->assign('data', $data['data']);

            if (isset($data['data']['status']) && $data['data']['status'] == 2) {
                $this->redirect('index');
            }

            return view();
        }

    }
}
